package edu.gdin.ecommerce.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import edu.gdin.ecommerce.util.DicConverter;

/**
 * Card entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "t_card", catalog = "ecommerce")
public class Card implements java.io.Serializable {

	// Fields

	
	/**
	 * 
	 */
	private static final long serialVersionUID = 5032012980473235898L;
	private Integer cardId;
	private String cardNo;
	private String password;
//	private Integer accountId;
//	private Integer cardIssuerId;
//	private Integer customerId;
	private Integer status;
	private Integer useType;
	private Integer materialType;
	private Date createTime;
	private Date expireTime;
	private Date updateTime;
	private String batchNo;
	private Integer mark;
	private Integer mainCardId;
	private Double mainCardExpense;
	private Double subCardExpense;
	private Date chargeTime;
	private String createUser;
	private String updateUser;
	private String cardDesc;
	
	private Account account;
	private CardIssuer cardIssuer;
//	private Customer customer;
//	private CardBatch cardBatch;
	

	// Constructors

	/** default constructor */
	public Card() {
	}

	/** full constructor */
	public Card(Integer cardId, String cardNo, String password, Integer status,
			Integer useType, Integer materialType, Date createTime,
			Date expireTime, Date updateTime, String batchNo, Integer mark,
			Integer mainCardId, Double mainCardExpense, Double subCardExpense,
			Date chargeTime, String createUser, String updateUser,
			String cardDesc, Account account, CardIssuer cardIssuer) {
		super();
		this.cardId = cardId;
		this.cardNo = cardNo;
		this.password = password;
		this.status = status;
		this.useType = useType;
		this.materialType = materialType;
		this.createTime = createTime;
		this.expireTime = expireTime;
		this.updateTime = updateTime;
		this.batchNo = batchNo;
		this.mark = mark;
		this.mainCardId = mainCardId;
		this.mainCardExpense = mainCardExpense;
		this.subCardExpense = subCardExpense;
		this.chargeTime = chargeTime;
		this.createUser = createUser;
		this.updateUser = updateUser;
		this.cardDesc = cardDesc;
		this.account = account;
		this.cardIssuer = cardIssuer;
	}

	// Property accessors
	@Id
	@GeneratedValue
	@Column(name = "CARD_ID", unique = true, nullable = false)
	public Integer getCardId() {
		return this.cardId;
	}

	public void setCardId(Integer cardId) {
		this.cardId = cardId;
	}

	@Column(name = "CARD_NO", nullable = false, length = 20)
	public String getCardNo() {
		return this.cardNo;
	}

	public void setCardNo(String cardNo) {
		this.cardNo = cardNo;
	}

	@Column(name = "PASSWORD", nullable = false, length = 20)
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

//	@Column(name = "ACCOUNT_ID", nullable = false)
//	public Integer getAccountId() {
//		return this.accountId;
//	}
//
//	public void setAccountId(Integer accountId) {
//		this.accountId = accountId;
//	}
//
//	@Column(name = "CARD_ISSUER_ID", nullable = false)
//	public Integer getCardIssuerId() {
//		return this.cardIssuerId;
//	}
//
//	public void setCardIssuerId(Integer cardIssuerId) {
//		this.cardIssuerId = cardIssuerId;
//	}
//
//	@Column(name = "CUSTOMER_ID", nullable = false)
//	public Integer getCustomerId() {
//		return this.customerId;
//	}
//
//	public void setCustomerId(Integer customerId) {
//		this.customerId = customerId;
//	}

	@Column(name = "STATUS", nullable = false)
	public Integer getStatus() {
		return this.status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	@Column(name = "USE_TYPE", nullable = false)
	public Integer getUseType() {
		return this.useType;
	}

	public void setUseType(Integer useType) {
		this.useType = useType;
	}

	@Column(name = "MATERIAL_TYPE", nullable = false)
	public Integer getMaterialType() {
		return this.materialType;
	}

	public void setMaterialType(Integer materialType) {
		this.materialType = materialType;
	}

	@Column(name = "CREATE_TIME", nullable = false, length = 19)
	public Date getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Column(name = "EXPIRE_TIME", length = 19)
	public Date getExpireTime() {
		return this.expireTime;
	}

	public void setExpireTime(Date expireTime) {
		this.expireTime = expireTime;
	}

	@Column(name = "UPDATE_TIME", length = 19)
	public Date getUpdateTime() {
		return this.updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	@Column(name = "BATCH_NO", nullable = false, length = 20)
	public String getBatchNo() {
		return this.batchNo;
	}

	public void setBatchNo(String batchNo) {
		this.batchNo = batchNo;
	}

	@Column(name = "MARK", nullable = false)
	public Integer getMark() {
		return this.mark;
	}

	public void setMark(Integer mark) {
		this.mark = mark;
	}

	@Column(name = "MAIN_CARD_ID")
	public Integer getMainCardId() {
		return this.mainCardId;
	}

	public void setMainCardId(Integer mainCardId) {
		this.mainCardId = mainCardId;
	}

	@Column(name = "MAIN_CARD_EXPENSE", precision = 12)
	public Double getMainCardExpense() {
		return this.mainCardExpense;
	}

	public void setMainCardExpense(Double mainCardExpense) {
		this.mainCardExpense = mainCardExpense;
	}

	@Column(name = "SUB_CARD_EXPENSE", precision = 12)
	public Double getSubCardExpense() {
		return this.subCardExpense;
	}

	public void setSubCardExpense(Double subCardExpense) {
		this.subCardExpense = subCardExpense;
	}

	@Column(name = "CHARGE_TIME", length = 19)
	public Date getChargeTime() {
		return this.chargeTime;
	}

	public void setChargeTime(Date chargeTime) {
		this.chargeTime = chargeTime;
	}

	@Column(name = "CREATE_USER", nullable = false, length = 20)
	public String getCreateUser() {
		return this.createUser;
	}

	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}

	@Column(name = "UPDATE_USER", length = 20)
	public String getUpdateUser() {
		return this.updateUser;
	}

	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}

	@Column(name = "CARD_DESC", length = 200)
	public String getCardDesc() {
		return this.cardDesc;
	}

	public void setCardDesc(String cardDesc) {
		this.cardDesc = cardDesc;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ACCOUNT_ID", nullable = false)
	public Account getAccount() {
		return account;
	}

	public void setAccount(Account account) {
		this.account = account;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "CARD_ISSUER_ID", nullable = false)
	public CardIssuer getCardIssuer() {
		return cardIssuer;
	}

	public void setCardIssuer(CardIssuer cardIssuer) {
		this.cardIssuer = cardIssuer;
	}

	
	public String markString(){
		return DicConverter.dicMapConvert("DIC_CARD_MARK", this.getMark());
	}
	
	public String statusString(){
		return DicConverter.dicMapConvert("DIC_CARD_STATUS", this.getStatus());
	}
	
	public String useTypeString(){
		return DicConverter.dicMapConvert("DIC_CARD_USE_TYPE", this.getUseType());
	}
	
	
//	@ManyToOne(fetch = FetchType.LAZY)
//	@JoinColumn(name = "CUSTOMER_ID", nullable = false)
//	public Customer getCustomer() {
//		return customer;
//	}
//
//	public void setCustomer(Customer customer) {
//		this.customer = customer;
//	}

//	@ManyToOne(fetch = FetchType.LAZY)
//	@JoinColumn(name = "BATCH_NO", nullable = false)
//	public CardBatch getCardBatch() {
//		return cardBatch;
//	}
//
//	public void setCardBatch(CardBatch cardBatch) {
//		this.cardBatch = cardBatch;
//	}

}